package com.tank.demo.entry.bullet;

import com.tank.demo.abstractFactory.BaseBullet;
import com.tank.demo.abstractFactory.BaseTank;
import com.tank.demo.entry.explode.RetroExplode;
import com.tank.demo.entry.tank.RetroTank;
import com.tank.demo.facadeAndMediator.GameModel;
import com.tank.demo.myenum.DirEnum;
import com.tank.demo.myenum.TankGroupEnum;
import com.tank.demo.utils.ResourceMgr;
import lombok.*;

import java.awt.*;

@Getter
@Setter
public class RetroBullet extends BaseBullet {
    public static final int SPEED = 20;

    public RetroBullet(Integer x, Integer y, DirEnum dir, TankGroupEnum group) {
        super(x, y, dir, group);
    }

    private void move() {
        if (x < 0 || y < 0 || x > GameModel.GAME_WIDTH || y > GameModel.GAME_HEIGHT) die();
        switch (dir) {
            case UP:
                y -= SPEED;
                break;
            case DOWN:
                y += SPEED;
                break;
            case LEFT:
                x -= SPEED;
                break;
            case RIGHT:
                x += SPEED;
                break;
        }
    }

    public void paint(Graphics g) {
        switch (dir) {
            case UP:
                g.drawImage(ResourceMgr.bulletU, x, y, null);
                break;
            case DOWN:
                g.drawImage(ResourceMgr.bulletD, x, y, null);
                break;
            case LEFT:
                g.drawImage(ResourceMgr.bulletL, x, y, null);
                break;
            case RIGHT:
                g.drawImage(ResourceMgr.bulletR, x, y, null);
                break;
        }
        move();
    }


}
